package com.mcode.blog.controller;

import com.mcode.blog.service.CommentsService;
import com.mcode.blog.vo.Result;
import com.mcode.blog.vo.params.CommentParams;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("comments")
public class CommentsController {

    @Resource
    private CommentsService commentsService;


    /**
     * 评论列表
     * @param articleId
     * @return
     */
    @GetMapping("/article/{id}")
    public Result comments(@PathVariable("id") Long articleId) {
        return Result.success(commentsService.getCommentByArticleId(articleId));
    }


    /**
     * 评论
     * @param commentParams
     * @return
     */
    @PostMapping("/create/change")
    public Result comment(@RequestBody CommentParams commentParams) {
        commentsService.comment(commentParams);
        return Result.success(null);
    }

}
